package com.tinem.platform.service.robot.im.core.plugin;

import com.tinem.platform.service.robot.im.core.Message;
import com.tinem.platform.service.robot.im.core.ReplyMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(999999)
public class HelloPlugin implements ApplicationListener<Message> {

    @Autowired
    private ApplicationContext applicationContext;

    @Override
    public void onApplicationEvent(Message event) {
        if(event.isEnd()){
            return;
        }
        ReplyMessage replyMessage = new ReplyMessage(event);
        replyMessage.setContent("hello:"+event.getContent());
        applicationContext.publishEvent(replyMessage);
    }
}
